#!/usr/bin/env python
# -*- coding:utf-8 -*-
from time import sleep

from selenium import webdriver


class MySpider:
    def __init__(self, driver_path, *args, **kwargs):
        """
        实例初始化函数
        :param driver_path: chrome driver 路径
        :param args: 无名参数，是一个 tuple
        :param kwargs: 有名参数，是一个 dict
        """
        self.driver_path = driver_path
        self.args = args
        self.kwargs = kwargs
        self.chrome_driver = webdriver.Chrome(executable_path=self.driver_path)

    @classmethod
    def shadiao(cls):
        print("shadiao")
        print(f"cls.__name__ = {cls.__name__}")
        pass

    def shadiao2(self):
        print("shadiao2")

    def run(self):
        self.chrome_driver.get("https://www.baidu.com/")
        print(f"self.driver_path = {self.driver_path}")
        print(f"self.args = {self.args}")
        print(f"self.kwargs = {self.kwargs}")
        sleep(5)
        self.chrome_driver.close()


if __name__ == '__main__':
    chrome_driver_path = "D:\\chromedriver.exe"
    chrome = MySpider(chrome_driver_path,  "fds", b=2, a=1)
    chrome.run()

